<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>数据集栅格查询</title>

    <link href="http://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
    <link href="http://cdn.bootcss.com/openlayers/4.2.0/ol.css" rel="stylesheet">
    <style>
        .ol-popup {
            position: absolute;
            background-color: white;
            -webkit-filter: drop-shadow(0 1px 4px rgba(0, 0, 0, 0.2));
            filter: drop-shadow(0 1px 4px rgba(0, 0, 0, 0.2));
            padding: 15px;
            border-radius: 10px;
            border: 1px solid #cccccc;
            bottom: 12px;
            left: -50px;
            min-width: 280px;
        }

        .ol-popup:after, .ol-popup:before {
            top: 100%;
            border: solid transparent;
            content: " ";
            height: 0;
            width: 0;
            position: absolute;
            pointer-events: none;
        }

        .ol-popup:after {
            border-top-color: white;
            border-width: 10px;
            left: 48px;
            margin-left: -10px;
        }

        .ol-popup:before {
            border-top-color: #cccccc;
            border-width: 11px;
            left: 48px;
            margin-left: -11px;
        }
    </style>
</head>
<body style=" margin: 0;overflow: hidden;background: #fff;width: 100%;height:100%">
<div id="map" style="width: 100%;height:100%"></div>
<div id="popup" class="ol-popup">
    <div id="popup-content"></div>
</div>

<script src="http://cdn.bootcss.com/openlayers/4.2.0/ol.js"></script>
<script type="text/javascript" src="../../dist/iclient9-openlayers.min.js"></script>
<script type="text/javascript">
    var container = document.getElementById('popup');
    var content = document.getElementById('popup-content');
    var overlay = new ol.Overlay(({
        element: container,
        autoPan: true,
        autoPanAnimation: {
            duration: 250
        }
    }));
    var map, baseUrl = "http://support.supermap.com.cn:8090/iserver/services/map-world/rest/maps/世界地图_Day",
            url = "http://support.supermap.com.cn:8090/iserver/services/data-world/rest/data";
    map = new ol.Map({
        target: 'map',
        controls: ol.control.defaults({attributionOptions: {collapsed: false}})
            .extend([new ol.supermap.control.Logo()]),
        view: new ol.View({
            center: [0, 0],
            zoom: 3,
            projection: 'EPSG:4326'
        }),
        overlays: [overlay]
    });
    var layer = new ol.layer.Tile({
        source: new ol.source.TileSuperMapRest({
            url: baseUrl

        }),
        projection: 'EPSG:4326'
    });
    map.addLayer(layer);

    map.on("click", function (evt) {
        var getGridCellInfosParam = new SuperMap.GetGridCellInfosParameters({
            dataSourceName: "World",
            datasetName: "WorldEarth",
            X: evt.coordinate[0],
            Y: evt.coordinate[1]
        });
        new ol.supermap.GridCellInfosService(url).getGridCellInfos(getGridCellInfosParam, function (serviceResult) {
            var result = serviceResult.result;
            var innerHTML = "栅格查询结果: " + "<br>" + "column: " + result.column + "<br>";
            innerHTML += "row: " + result.row + "<br>";
            innerHTML += "value: " + result.value + "<br>";
            content.innerHTML = innerHTML;
            overlay.setPosition([evt.coordinate[0], evt.coordinate[1]]);
        });
    });
</script>
</body>
</html>